package com.example.work_study_system.web.controller;

import com.example.work_study_system.model.domain.PositionApplication;
import com.example.work_study_system.service.PositionApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/positionApplication")
public class PositionApplicationController {
    @Autowired
    private PositionApplicationService positionApplicationService;

    @GetMapping("/list")
    public List<PositionApplication> list() {
        return positionApplicationService.list();
    }

    @GetMapping("/{id}")
    public PositionApplication getById(@PathVariable Integer id) {
        return positionApplicationService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody PositionApplication positionApplication) {
        return positionApplicationService.save(positionApplication);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody PositionApplication positionApplication) {
        return positionApplicationService.updateById(positionApplication);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return positionApplicationService.removeById(id);
    }
} 